home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11645 < prev    next >
Encoding:
Text File  |  1996-08-05  |  899 b   |  28 lines

  1. Newsgroups: comp.lang.c
  2. Path: mxsld2.pd.infn.it!LORETI
  3. From: loreti@mxsld2.pd.infn.it (Maurizio Loreti)
  4. Subject: Re: leap year
  5. X-Nntp-Posting-Host: mxsld2.pd.infn.it
  6. Message-ID: <Dov6qE.EwC@news.cern.ch>
  7. Sender: news@news.cern.ch (USENET News System)
  8. Reply-To: loreti@mxsld2.pd.infn.it
  9. Organization: I.N.F.N. Padova - CDF/CMS VAXcluster
  10. References: <4iq64e$evq@daryl.scsn.net>
  11. Date: Tue, 26 Mar 1996 07:42:08 GMT
  12.  
  13. In article <4iq64e$evq@daryl.scsn.net>, shrader@scsn.net (Scott Shrader) writes:
  14. >can anyone tell me in C how do I write a program so it can tell me if a 
  15. >year is a leap year.
  16.  
  17. ... another way is to code
  18.  
  19. if (year % 4 == 0  &&  (year % 100 != 0  ||  year % 400 == 0)) {
  20.   /* year is a leap year */
  21. } else {
  22.   /* not. */
  23. }
  24.  
  25. --
  26. Maurizio Loreti                       http://mvxpd5.pd.infn.it/wwwcdf/mlo.html
  27. Un. of Padova, Dept. of Physics - Padova, Italy          loreti@padova.infn.it
  28.